﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BL;
using DA;
using System.Text.RegularExpressions;
using Entities;
using ERP.Membership;

namespace ERP.UserControl
{
    public partial class CreateNewOrderButton : System.Web.UI.UserControl
    {
        OrderManager orderManager = new OrderManager();

        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void on_click_create_order(object sender, EventArgs e)
        {
            ERPMembership erpm = new ERPMembership();
            UserData ud = erpm.GetCurrentLoggedInUser();
            ERP_Orders newOrder = new ERP_Orders();
            newOrder.CreationDate = DateTime.Now;
            newOrder.UserId = ud.UserId;
            
            if (orderManager.AddOrder(newOrder))
            {
                Response.Redirect("OrderForm.aspx?OrderId=" + newOrder.OrderId, true);
            }
        }
    }
}